package com.sandasai.action.teacher;
import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.sandasai.service.TeacherManager;
import com.sandasai.vo.TeacherBean;
@Controller
@Scope("prototype")
public class UpdateInfoAction extends ActionSupport {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private String bankCardId;
    private String jobId;
    private String position;
    private String realName;
    private String tel;
    private String workUnit;
    @Resource
	private TeacherManager teacherManager;
    
    public String getBankCardId() {
        return bankCardId;
    }
    public void setBankCardId(String bankCardId) {
        this.bankCardId = bankCardId;
    }
    public String getJobId() {
        return jobId;
    }
    public void setJobId(String jobId) {
        this.jobId = jobId;
    }
    public String getPosition() {
        return position;
    }
    public void setPosition(String position) {
        this.position = position;
    }
    public String getRealName() {
        return realName;
    }
    public void setRealName(String realName) {
        this.realName = realName;
    }
    public String getTel() {
        return tel;
    }
    public void setTel(String tel) {
        this.tel = tel;
    }
    public String getWorkUnit() {
        return workUnit;
    }
    public void setWorkUnit(String workUnit) {
        this.workUnit = workUnit;
    }
    /**
     * @return
     */
    public String execute() throws Exception{
        ActionContext ctx = ActionContext.getContext();
        
        TeacherBean teacherBean = new TeacherBean();
        teacherBean.setUsername((String) ctx.getSession().get("username"));
        teacherBean.setBankCardId(bankCardId);
        teacherBean.setJobId(jobId);
        teacherBean.setPosition(position);
        teacherBean.setRealName(realName);
        teacherBean.setTel(tel);
        teacherBean.setWorkUnit(workUnit);
        if(teacherManager.updateInfo(teacherBean)) {
        	ctx.put("teacherBean", teacherBean);
            ctx.put("message", "更新成功！");
            return SUCCESS;
        }else {
        	TeacherBean teacherBean2 = teacherManager.getTeacherBean((String) ctx.getSession().get("username"));
            ctx.put("teacherBean", teacherBean2);
            ctx.put("message", "更新失败！");
            return ERROR;
        }
        
    }
}